
#ifndef SPRITE_H
#define SPRITE_H

// INCLUDES ********************************************************************

#include "Vector2D.h"

#include "Rectangle.h"

#include "Drawable.h"

#include "Datatypes.h"

#include <string>


// FORWARD DECLARATIONS ********************************************************

namespace Meteor 
{
    class Texture2D;
}

// *****************************************************************************

//! Sprite
//! 
//! General sprite class, will act as base for others ( animated sprite etc.)

// *****************************************************************************

namespace Meteor 
{
    class Sprite : public Drawable
    {
        public:
            explicit Sprite( const std::string& fileName);
            
            Sprite( const std::string& fileName, const uint32_t zIndex);
        
            Sprite( const Sprite& sprite);
        
            Sprite& operator=( const Sprite& rhs);
        
            virtual ~Sprite();
            
            //! return a reference to this sprite's texture, to used it with
            //! another sprite for example
            virtual void SetTextureRect( const Rectangle& rect);
            
            Texture2D* const Texture() const;
        
            const std::string& FileName() const;
            
            //! size
            virtual void SetSize( const float width, const float height);
            
            virtual void SetSize( const Vector2D& newSize);
            
            
            //! set this sprites blendfunction
            void SetBlendFunc( const GLenum src, const GLenum dest);
            
            void SetBlendFunc( const BlendFunction& blendFunc);

            //! set texture parameters ( GL_REPEAT etc.)
            //! NOTE: certain parameters will heavily influence the way
            //! the object is displayed ( for example: non POT textures will
            //! only work with 'GL_CLAMP_TO_EDGE')
            void SetGLParameter( const GLenum name, const GLenum value);
            
            //! logical changes
            virtual void Update( const float deltaTime);
            
            //! handling GL stuff
            virtual void Draw() const;
        
        protected:
            //! the associated image as an opengl texture
            Texture2D* mTexture;
            
            //! the vertices for the sprite drawn
            std::vector<float> mVertices;
            
            //! blend function used with this sprite
            BlendFunction mBlendFunc;

        private:
            void Initialize( const std::string& fileName);
        
            std::string mFileName;


    }; // end of class Sprite    

} // end of namespace Meteor

#endif
